﻿Imports System.Data.SqlClient

Public Class Listados

    Private Sub PoblarReporte(ByVal Numero As Int32)
        Dim sqlConn As SqlConnection
        Dim sqlDaLin As New SqlDataAdapter
        Dim sqlDaCab As New SqlDataAdapter
        Dim sqlCmd As New SqlCommand
        Dim dsPc As New dsPedidos
        Dim strConn As String = "Server=localhost,4433;Initial Catalog=furniture;" & _
          "Integrated Security = SSPI;User ID=localusr;Password=geronimo1502"

        Try
            'Crear los DataAdapters
            sqlConn = New SqlConnection(strConn)
            With sqlCmd
                .Connection = sqlConn
                .CommandText = "ListaCabPedido"
                .CommandType = CommandType.StoredProcedure
                .Parameters.AddWithValue("@Numero", Numero)
            End With

            sqlDaCab.SelectCommand = sqlCmd
            sqlDaCab.Fill(dsPc, "ListaCabPedido")

            With sqlCmd
                '.Connection = sqlConn
                .CommandText = "ListaLnPedido"
                '.CommandType = CommandType.StoredProcedure
                '.Parameters.AddWithValue("@Numero", Numero)
            End With

            sqlDaLin.SelectCommand = sqlCmd
            sqlDaLin.Fill(dsPc, "ListaLnPedido")

            'Poblar el informe con el dataSet y mostrarlo
            Dim info As New rptPedido
            info.SetDataSource(dsPc)
            crvListado.ReportSource = info
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
        End Try
    End Sub

    Public Sub New(ByVal Numero As Int32)

        ' Llamada necesaria para el Diseñador de Windows Forms.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        PoblarReporte(Numero)
    End Sub

    Private Sub Listados_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated

    End Sub
End Class